﻿using System;
using System.Collections.Generic;
using System.Text;
using JsonSharp;
using Barbar.MapReport.Common.Drawing;
using JsonSharp.Collections;
using JsonSharp.Values;

namespace Barbar.MapReport.HtmlRender.Json {
  internal class GeoRegionFactory : JsonFactory {
    private RegionList m_GeoRegion;

    public GeoRegionFactory(RegionList geoRegion) {
      m_GeoRegion = geoRegion;
    }

    public override JsonValue ToJsonObject() {
      JsonObjects result = new JsonObjects();
      JsonArrays jsonRegionIds = new JsonArrays();
      foreach (string regionId in m_GeoRegion.RegionIds)
        jsonRegionIds.Add(new JsonStringValue(regionId));
      result.Add(new JsonStringValue("RegionIds"), jsonRegionIds);
      result.Add(new JsonStringValue("ToolTip"), new JsonStringValue(m_GeoRegion.ToolTip));

      return result;
    }
  }
}
